<?php
use yii\helpers\Url;
?>
<style>
    .mui-input-group {
        margin-top: 10px;
    }

    .mui-input-group:first-child {
        margin-top: 20px;
    }

    .mui-input-group label {
        width: 28%;
    }

    .mui-input-row label~input,
    .mui-input-row label~select,
    .mui-input-row label~textarea {
        width: 72%;
    }
</style>
<div class="login-portrait">
    <img src="/images/login.png" />
</div>
<form id='login-form' class="mui-input-group">
    <div class="mui-input-row">
        <label>用户名</label>
        <input id='account' type="text" name="username" class="mui-input-clear mui-input" placeholder="请输入用户名">
    </div>
    <div class="mui-input-row">
        <label>密码</label>
        <input id='password' name="password" type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
    </div>
    <div class="mui-input-row">
        <label>确认密码</label>
        <input id='password2' name="repassword" type="password" class="mui-input-clear mui-input" placeholder="请输入确认密码">
    </div>
    <div class="mui-input-row">
        <label>QQ号码</label>
        <input id='qq' type="text" name="qq" class="mui-input-clear mui-input" placeholder="请输入QQ号码">
    </div>
    <div class="mui-input-row">
        <label>邀请码</label>
        <input id='invite_code' type="text" name="invite_code" class="mui-input-clear mui-input" value="<?php echo Yii::$app->request->get("id"); ?>" placeholder="邀请人代码（必填）">
    </div>
</form>
<div class="mui-content-padded">
    <button id='reg' class="mui-btn mui-btn-block mui-btn-primary" style="padding:6px 0;">注册账号</button>
    <div class="link-area"><a id='login' href="<?php echo Url::toRoute("site/login"); ?>">登陆</a> 
    </div>
</div>
<script>
    (function ($, doc) {
        $.init({
            statusBarBackground: '#f7f7f7'
        });
        //检查 "登录状态/锁屏状态" 结束
        var regButton = doc.getElementById('reg');
        var accountBox = doc.getElementById('account');
        var passwordBox = doc.getElementById('password');
        var passwordBox2 = doc.getElementById('password2');
        var qqBox = doc.getElementById('qq');
        var codeBox = doc.getElementById('invite_code');
        regButton.addEventListener('tap', function (event) {
            var regInfo = {
                username: accountBox.value,
                password: passwordBox.value,
                repassword: passwordBox2.value,
                qq: qqBox.value,
                invite_code: codeBox.value
            };
            app.regist(regInfo, function (err) {
                if (err) {
                    mui.toast(err);
                    return;
                }
                 window.location.herf = "/site/login.html";
            });
        });
    }(mui, document));
</script>